package cn.edu.fjzzit.web.myhotel.controller;

import cn.edu.fjzzit.web.myhotel.config.ResultJson;
import cn.edu.fjzzit.web.myhotel.dto.RoomOrderDTO;
import cn.edu.fjzzit.web.myhotel.service.RoomService;
import cn.edu.fjzzit.web.myhotel.dto.FreeRoomDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/room_order")
@Api(tags = "订房管理")
public class RoomOrderController {
    @Autowired
    private RoomService roomService;

    @GetMapping("/free_room")
    @ApiOperation("查询空房")
    @RequiresAuthentication

    public ResultJson getFreeRoom(String checkInDate,String checkOutDate){
        try{
            List<FreeRoomDTO> freeRoomDTOList = roomService.findFreeRoom(checkInDate,checkOutDate);
            return  new ResultJson("200","查询成功",freeRoomDTOList);

        }catch(Exception e){
            return new ResultJson("400","查询失败",null);
        }

    }

   public ResultJson bookingOrder(@RequestBody RoomOrderDTO roomOrderDTO) {
        return null;
   }
}
